package huxibianjie.com.lbscandroid.ui.old;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;


import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import huxibianjie.com.lbscandroid.R;
import huxibianjie.com.lbscandroid.model.RankingsModel;


/**
 * Created by wangtao on 2018/6/11.
 */

public class NearbyRankingsAdapter extends RecyclerView.Adapter {

    private List<RankingsModel.RankingsBean> datas;


    public void setDatas(List<RankingsModel.RankingsBean> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.nearby_rankings, parent,false);
        RecyclerView.ViewHolder viewHolder = new MoneyViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ((MoneyViewHolder) holder).setData(position);
    }

    @Override
    public int getItemCount() {
        return datas == null ? 0 : datas.size();
    }

    class MoneyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.ranking)
        TextView mRanking;
        @BindView(R.id.Today_money)
        TextView mTodayMoney;
        @BindView(R.id.rl)
        RelativeLayout mRl;
        @BindView(R.id.view)
        View view;
        @BindView(R.id.phonenumber)
        TextView phonenumber;
        @BindView(R.id.set_jiangli)
        TextView setjiangli;

        public MoneyViewHolder(View inflate) {
            super(inflate);
            ButterKnife.bind(this, inflate);
        }

        public void setData(int position) {
            mRanking.setText(position+1+"");
            phonenumber.setText(datas.get(position).getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2")+"");
            mTodayMoney.setText(datas.get(position).getStep() + "");
            setjiangli.setText(" +"+(500-(position*30))+ "");

        }

    }
}
